export default function (params) {
    let data = params.slice(0,8)
    data.map(item => {
        item.city = item.city.substring(item.city.indexOf('/')+1)
        return item
    })
    var m2R2Data = [{
        value: 335,
        legendname: '种类01',
        name: "种类01  335",
        itemStyle: {
          color: "#8d7fec"
        }
      },
      {
        value: 310,
        legendname: '种类02',
        name: "种类02  310",
        itemStyle: {
          color: "#5085f2"
        }
      },
      {
        value: 234,
        legendname: '种类03',
        name: "种类03  234",
        itemStyle: {
          color: "#e75fc3"
        }
      },
      {
        value: 154,
        legendname: '种类04',
        name: "种类04  154",
        itemStyle: {
          color: "#f87be2"
        }
      },
      {
        value: 335,
        legendname: '种类05',
        name: "种类05  335",
        itemStyle: {
          color: "#f2719a"
        }
      },
      {
        value: 335,
        legendname: '种类06',
        name: "种类06  335",
        itemStyle: {
          color: "#fca4bb"
        }
      },
      {
        value: 335,
        legendname: '种类07',
        name: "种类07  335",
        itemStyle: {
          color: "#f59a8f"
        }
      },
      {
        value: 335,
        legendname: '种类08',
        name: "种类08  335",
        itemStyle: {
          color: "#fdb301"
        }
      },
  
    ];

    m2R2Data?.forEach((item,index) => {
        item.value = data[index]?.salesAmount
        item.legendname = data[index]?.city
        item.name = data[index]?.city
    })
    
    return {
      backgroundColor: '#fff',
      title: [{
          text: '销量统计',
          textStyle: {
              fontWeight: 'normal',
            fontSize: 16,
            color: "black"
          },
          left: "2%"
        },
        {
          text: '合计',
          subtext: 12312 + '个',
          textStyle: {
            fontSize: 14,
            color: "black"
          },
          subtextStyle: {
            fontSize: 14,
            color: 'black'
          },
          textAlign: "center",
          x: '44%',
          y: '45%',
        }
      ],
      tooltip: {
        trigger: 'item',
        formatter: function (parms) {
          var str = parms.seriesName + "</br>" +
            parms.marker + "" + parms.data.legendname + "</br>" +
            "数量：" + parms.data.value + "</br>" +
            "占比：" + parms.percent + "%";
          return str;
        }
      },
      
      series: [{
        name: '标题',
        type: 'pie',
        center: ['46%', '56%'],
        radius: ['40%', '65%'],
        clockwise: false, //饼图的扇区是否是顺时针排布
        avoidLabelOverlap: false,
        label: {
          normal: {
            show: true,
            position: 'outter',
            formatter: function (parms) {
              return parms.data.legendname
            }
          }
        },
        labelLine: {
          normal: {
            length: 5,
            length2: 3,
            smooth: true,
          }
        },
        data: m2R2Data
      }]
    };
    
}
